﻿using System;
using ZX.BLL.Extend;
using System.Collections.Generic;
using lite;
using OpenExpressApp.DB.Utils;
using System.Data;
using ZX.DAL;
using ZX.DAL.DBExtend;
namespace ZX.CRM.Bussiness
{
    public class BCrmSubjectManager : BaseBussnies
    {


        public BCrmSubjectManager() { }
        public List<SubjectList> GetSubjectList()
        {
            DataTable dt = new DataTable();
            List<SubjectList> TFlist = new List<SubjectList>();
            string strSql = string.Format("select c.id as cid,c.SubjectName as cname,p.id as pid,p.SubjectName as pname from CrmSubjectManager as p inner join CrmSubjectManager as c on c.SuperiorSubjectID=p.ID where p.SubjectClassID='037B64D2-1B99-4A2E-A7EE-089023AC8CE6' and c.SubjectClassID='037B64D2-1B99-4A2E-A7EE-089023AC8CE6' Order BY p.SubjectName");
            DbSql db = new DbSql();
            dt = db.ExecuteQuery(strSql);

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    SubjectList sj = new SubjectList();
                    sj.cid = (dr["cid"] == null) ? "" : dr["cid"].ToString();
                    sj.cname = (dr["cname"] == null) ? "" : dr["cname"].ToString();
                    sj.pid = (dr["pid"] == null) ? "" : dr["pid"].ToString();
                    sj.pname = (dr["pname"] == null) ? "" : dr["pname"].ToString();
                    TFlist.Add(sj);
                }
              
            }
            return TFlist;
        }
        public class SubjectList 
        {
           // cid,cname,pid,pname
            public string cid { get; set; }
            public string cname { get; set; }
            public string pid { get; set; }
            public string pname { get; set; }

            public SubjectList() { }
        
        }

    }
}
